export default {

	savepic: function(picurl) {
		uni.downloadFile({
			url: picurl,
			success: (res) => {
				if (res.statusCode === 200) {
					uni.saveImageToPhotosAlbum({
						filePath: res.tempFilePath,
						success: function() {
							uni.showToast({
								title: "保存成功",
								icon: "none"
							});
						},
						fail: function() {
							uni.showToast({
								title: "保存失败，请稍后重试",
								icon: "none"
							});
						}
					});
				}
			}
		})
	},


	copyTxt: function(data) {

		// #ifdef H5

		let textarea = document.createElement("textarea")
		textarea.value = data
		textarea.readOnly = "readOnly"
		document.body.appendChild(textarea)
		textarea.select() // 选择对象
		textarea.setSelectionRange(0, data.length) //核心
		let result = document.execCommand("Copy") // 执行浏览器复制命令
		textarea.remove()

		uni.showToast({
			title: "复制成功",
			icon: "none"
		});
		return result
		// #endif		

		uni.setClipboardData({
			data: data,
			success: function() {
				uni.showToast({
					title: "复制成功",
					icon: "none"
				});
			}
		});




	}
}
